<?php
/**
 * twitter.update.php
 *
 * Author: JohnGR
 * Created: 03/12/2009
 * Last Modified: 14/12/2009
 * Depends on files: yes (twitter.class.php)
 *
 */
 
	// Enter your twitter credentials here, save the file and you are set! :)
	///////////////////////////////////////////////////////////////////////////////
	///////////////////////////////////////////////////////////////////////////////
	$username = 'your_twitter_username_here';
	$password = 'your_twitter_password_here';
	///////////////////////////////////////////////////////////////////////////////
	///////////////////////////////////////////////////////////////////////////////
	//////////////// You don't need to edit anything below ////////////////////////
	
	
	// Include the twitter class 
	require("twitter.class.php");
	
	/** 
	 * update_status($tweet, $username, $password)
	 * 
	 * Last Modified: 14/12/2009
	 * 
	 * Update status on twitter
	 *
	 * @par: $tweet, The message to be posted to twitter
	 * @par: $username, The twitter username
	 * @par: $password, The twitter password
	 *
	 */
	function update_status($tweet, $username, $password)
	{
			$twitter =  new MyTwitter($username, $password);
			
			$result = $twitter->updateStatus($tweet);
			
			if ($result == 1)
			echo "<div class=\"msg-ok radius\">Status updated!</div>";
			else
			echo $result;
	}
	
	// Call function to update status on twitter if we have the ajax call with the post variable
	if ($_POST["tweet"]) {
		$tweet = $_POST["tweet"];
		
		update_status($tweet, $username, $password);
	}
?>